import {createStore} from 'vuex'
import moduleA from './modules/moduleA'
import moduleB from './modules/moduleB'

//创建一个新的store/vuex实例
const store = createStore({
    modules:{
        a:moduleA,
        b:moduleB
    },
    state(){
        return{
            count:200
        }
    },
    getters:{
        tenTimes:(state)=>{
            return state.count * 10
        }
    },
    mutations:{
        incrementMut(state,playload){
            //更新state
            state.count = playload.count
        }
    },
    actions:{
        incrementAct(context,playload){
            setTimeout(()=>{
                context.commit('incrementMut',playload)
            },3000)
        }
    }
})

export default store